﻿parent(igor, victor).
parent(olga, victor).
parent(igor, sasha).
parent(olga, sasha).
parent(igor, ivan).
parent(olga, ivan).
parent(victor, oleg).
parent(elena, oleg).
parent(victor, marina).
parent(elena, marina).
parent(oleg, andrey).
parent(tatiana, andrey).
parent(oleg, kolya).
parent(tatiana, kolya).
parent(petr, nadezhda).

person(kolya, 17, male).
person(sasha, 38, male).
person(igor, 80, male).
person(olga, 73, female).
person(victor, 55, male).
person(elena, 50, female).
person(oleg, 26, male).
person(marina, 30, female).
person(tatiana, 25, female).
person(andrey, 3, male).
person(petr, 33, male).
person(nadezhda, 7, female).
person(ivan, 55, male).

mother(X, Y) :- parent(X, Y), person(X, _, female).
father(X, Y) :- parent(X, Y), person(X, _, male).

incorrectdb :- parent(X, X).
incorrectdb :- mother(X, Z), mother(Y, Z).

brother(Brother, Person) :- mother(Mother, Brother), mother(Mother, Person), person(Brother, _, male), person(Person, _, _), Brother \= Person.
grand_father(Grandfather, Grandchild) :- father(Grandfather, Child), parent(Child, Grandchild).
